package com.sam.listener;

import com.sam.schedule.ScheduleServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.event.ApplicationReadyEvent;
import org.springframework.context.ApplicationListener;
import org.springframework.stereotype.Component;


@Component
@Slf4j
public class StartListener implements ApplicationListener<ApplicationReadyEvent> {

    @Autowired
    private ScheduleServiceImpl scheduleServiceImpl;

    @Override
    public void onApplicationEvent(ApplicationReadyEvent applicationReadyEvent) {
        log.info("项目启动成功完成");
        scheduleServiceImpl.startJob();
    }
}